<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0 auto;
        }
        .box {
            text-align: center;
            border: 1px solid black;
            width: 400px;
            height: 200px;
            padding-top: 197px;
        }
    </style>
</head>
<body>
    <div class="box">
        <div class="tip">5s后跳转页面</div>
    </div>
    <script>
        var tip = document.querySelector('.tip');
        var rest = 5000;
        var timer = setInterval(function() {
            if (rest == 0) {
                clearInterval(timer);
                location.href = 'http://www.itcast.cn';
            }else {
                rest -= 1000;
                tip.innerText = (rest / 1000) + 's后跳转页面';
            }
        }, 1000)
    </script>
</body>
</html>